package cn.anzhiyublog.staranimegallery.service;

import cn.anzhiyublog.staranimegallery.model.domain.Picture;
import cn.anzhiyublog.staranimegallery.model.domain.User;
import cn.anzhiyublog.staranimegallery.model.dto.picture.*;
import cn.anzhiyublog.staranimegallery.model.vo.PictureVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 图片层接口
 *
 * @author 安知一只鱼
 */
public interface PictureService extends IService<Picture> {
    /**
     * 通过文件上传图片
     */
    Picture uploadPictureByFile(MultipartFile pictureFile, PictureUploadRequest pictureUploadRequest, User loginUser);

    /**
     * 通过url上传图片
     */
    Picture uploadPictureByUrl(PictureUrlUploadRequest pictureUrlUploadRequest, User loginUser);

    /**
     * 通过爬虫上传图片（仅管理员）
     */
    PictureSpiderUploadResult uploadPictureBySpider(PictureSpiderUploadRequest pictureSpiderUploadRequest, User loginUser);

    /**
     * 删除图片（本人或者管理员）
     */
    void deletePicture(PictureDeleteRequest pictureDeleteRequest, User loginUser);

    /**
     * 修改图片（管理员或本人）
     */
    void updatePicture(PictureUpdateRequest pictureUpdateRequest, User loginUser);

    /**
     * id查询图片
     */
    Picture getPictureById(long pictureId, User loginUser);

    /**
     * 分页查询图片
     */
    Page<Picture> listPictureByPage(PicturePageQueryRequest picturePageQueryRequest, User loginUser);

    /**
     * 分页查询图片（带缓存机制）
     */
    Page<Picture> listPictureByPageWithCache(PicturePageQueryRequest picturePageQueryRequest, User loginUser);

    /**
     * 审核图片(仅管理员)
     */
    void reviewPicture(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 脱敏数据
     */
    PictureVO ObjToVO(Picture picture);

    /**
     * 批量脱敏
     */
    List<PictureVO> ObjToVO(List<Picture> pictures);

    /**
     * 随机图片(带缓存机制)
     */
    List<Picture> randomPicturesWithCache(int number);

    /**
     * 删除空间下所有的图片
     */
    void deletePicturesBySpaceId(long spaceId, User loginUser);

    /**
     * 清除图片缓存
     */
    void clearPictureCache();
}
